#include <iostream>
#include <typeinfo>
#include <cstddef>  // For nullptr

using namespace std;

class student_t {
  private: // 私有的
    const char *name;
    int         age;
    float       score;

  public: // 共有的
    student_t(const char *name, const int age, float score);
    ~student_t();
    void show();
};

// 构造函数
student_t::student_t(const char *name, const int age, float score)
{
    this->name = name;
    this->age = age;
    this->score = score;
    cout << "[student_t()] this pointer type (via typeid): " << typeid(this).name() << "."
         << this->name << "的年龄是" << this->age << "，成绩是" << this->score << endl;
}

// 析构函数
student_t::~student_t()
{
    cout << "[~student_t()] this pointer type (via typeid): " << typeid(this).name() << "."
         << this->name << "的年龄是" << this->age << "，成绩是" << this->score << endl;
}

void student_t::show()
{
    // Note: typeof is not standard C++, we use typeid from <typeinfo> instead
    // typeid(this).name() returns a compiler-dependent mangled type name
    cout << "[show()] this pointer type (via typeid): " << typeid(this).name() << "."
         << this->name << "的年龄是" << this->age << "，成绩是" << this->score << endl;
}

int main()
{
    // 调用构造函数 Student(char *, int, float)
    student_t stu("sumu", 18, 98.9);
    stu.show();

    return 0;
}
